package com.ex03.ylw.connector.http;

import com.util.PackagePath;
import org.apache.catalina.util.StringManager;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

/**
 * 更有效的读取头信息
 * Created by yangliwei on 2017/7/25.
 */
public class SocketInputStream extends InputStream {


    /**
     * CR.
     */
    private static final byte CR = (byte) '\r';


    /**
     * LF.
     */
    private static final byte LF = (byte) '\n';


    /**
     * SP.
     */
    private static final byte SP = (byte) ' ';


    /**
     * HT.
     */
    private static final byte HT = (byte) '\t';


    /**
     * COLON.
     */
    private static final byte COLON = (byte) ':';


    /**
     * Lower case offset.
     */
    private static final int LC_OFFSET = 'A' - 'a';


    /**
     * Internal buffer.
     */
    protected byte buf[];


    /**
     * Last valid byte.
     */
    protected int count;


    /**
     * Position in the buffer.
     */
    protected int pos;


    /**
     * Underlying input stream.
     */
    protected InputStream is;


    // ----------------------------------------------------------- Constructors


    /**
     * Construct a servlet input stream associated with the specified socket
     * input.
     *
     * @param is         socket input stream
     * @param bufferSize size of the internal buffer
     */
    public SocketInputStream(InputStream is, int bufferSize) {

        this.is = is;
        buf = new byte[bufferSize];

    }

    /**
     * The string manager for this package.
     */
    protected static StringManager sm =
            StringManager.getManager(PackagePath.EX3.getPath());

    public void readRequestLine(HttpRequestLine requestLine)
            throws IOException {
    }


    @Override
    public int read() throws IOException {
        return 0;
    }
}
